<?php
namespace app\index\model;
use think\Model;
class base extends Model{
    protected function initialize(){
        parent::initialize();
    }
    public function baseInfo($district,$CITY,$province,$street,$pyGetName)
    {
        $map=['OBJECTID','longtitude','latitude','GB_CODE','name','abbreviation','city','province','tel','remark','abvProvince','fullName','abbreviationThree','POP_ALL','POP_COUNTRYSIDE','POP_TOWN','GDP','FST_INDUSTRY','SND_INDUSTRY','TRD_INDUSTRY','townNum','villageNum','climate','area','altitudeL','altitudeLName','altitudeH','altitudeHName','altitudeAverage','topographic','villageAverIncom','urbanAverIncome','Population','Economics'];        
        $condition = [
            ['like',$this->base_strsub($street)],
            ['like',$this->base_strsub($district)],
            ['like',$this->base_strsub($CITY)],
            ['like',$this->base_strsub($province)],
            ['like',$this->base_strsub($pyGetName)]
        ];
        $res=$this->field($map)->where('name',$condition,'OR')->select();
        // $res=$this->field($map)->where('abbreviation','like', '%'.$province.'%')->select()  ->fetchSql();
        return $res;
        # code...
    }

    protected function base_strsub($str)
    {
        if($str!=''){
        $res = mb_substr($str,0,mb_strlen($str,'utf-8')-1,'utf-8');
        return $res.'%';
        }else{
            return $str;
        }
    }
}
